aliyunApi=require './api/aliyunApi'
express=require 'express'
app=express()

config ={'Action':'DescribeInstances','RegionId':'cn-beijing'}
api=new aliyunApi(config)

app.set 'view engine','jade'
app.set 'views','./views'
app.use express.static('views')
app.use express.static('public')
app.use express.static('bower_components')



app.get '/',(req,res)->
  res.render 'index'


app.get '/api',(req,res)->

  api.getInstances (result)->

    res.send result

app.get '/region',(req,res)->
  api.setConfig {'Action':'DescribeRegions'}
  .getInstances (result)->
    res.send result

app.get '/zones',(req,res)->
  api.setConfig {'Action':'DescribeZones','RegionId':'cn-beijing'}
  .getInstances (result)->
    res.send result
app.listen 7777,()->
  console.log 'the server is running at port',7777









